From a89ca90f136cfdf71beddc35ed269062dc3ca3f9 Mon Sep 17 00:00:00 2001 From: robertl Date: Tue, 30 Jun 2009 02:58:06 +0000 Subject: [PATCH] Delbin: fix infinite read in depacketizer. linux hid: parsing fixes. Doc improvements. --- delbin.c | 20 ++++++++--------- xmldoc/formats/delbin.xml | 47 +++++---------------------------------- 2 files changed, 16 insertions(+), 51 deletions(-) diff --git a/delbin.c b/delbin.c index eebdac42e..e46a68bd5 100644 --- a/delbin.c +++ b/delbin.c @@ -530,6 +530,7 @@ read_depacketize_1(gbuint8** p, unsigned n, int new_packet) static unsigned buf_i, buf_n; while (buf_n == 0 || new_packet) { packet_read(buf); + new_packet = FALSE; if (buf[1] <= delbin_os_packet_size - 2) { buf_n = buf[1]; buf_i = 2; @@ -1984,8 +1985,10 @@ delbin_rw_init(const char *fname) warning(MYNAME ": device %s %s\n", p->product, p->firmware); if (opt_long_notes) { use_extended_notes = TRUE; + } else if (strstr(p->product, "PN-20")) { + use_extended_notes = p->firmware[0] > '1' || + (p->firmware[0] == '1' && p->firmware[2] >= '6'); } else if (strstr(p->product, "PN-40")) { - // Don't know if pre-2.5 PN-40 firmware or PN-20 can handle 0xb016 message use_extended_notes = p->firmware[0] > '2' || (p->firmware[0] == '2' && p->firmware[2] >= '5'); } @@ -2034,11 +2037,7 @@ delbin_write(void) static waypoint* delbin_rd_position(posn_status* status) { - waypoint* wp = read_position(); - if (wp == NULL) { - status->request_terminate = 1; - } - return wp; + return read_position(); } ff_vecs_t delbin_vecs = { @@ -2468,20 +2467,21 @@ linuxhid_os_init(const char* fname) fd_hidraw = fd_hiddev = -1; if (fname && memcmp(fname, "hid:", 4) == 0) { - const char* raw_name = fname + 4; - const char* dev_name = strchr(raw_name, ','); + char* raw_name = xstrdup(fname + 4); + char* dev_name = strchr(raw_name, ','); if (dev_name == NULL) { - fatal(MYNAME ": missing hiddev\n"); + fatal(MYNAME ": missing hiddev path\n"); } + *dev_name++ = 0; fd_hidraw = open(raw_name, O_RDONLY); if (fd_hidraw < 0) { fatal(MYNAME ": %s: %s\n", raw_name, strerror(errno)); } - dev_name++; fd_hiddev = open(dev_name, O_WRONLY); if (fd_hiddev < 0) { fatal(MYNAME ": %s: %s\n", dev_name, strerror(errno)); } + xfree(raw_name); } else { dir = opendir("/dev"); } diff --git a/xmldoc/formats/delbin.xml b/xmldoc/formats/delbin.xml index 94ac35403..3b7280f1c 100644 --- a/xmldoc/formats/delbin.xml +++ b/xmldoc/formats/delbin.xml @@ -1,5 +1,5 @@ - The 'delbin' module supports Delorme PN-20, PN-30, and PN-40 receivers. + The 'delbin' module supports DeLorme PN-20, PN-30, and PN-40 receivers. Not all strains of Linux are supported. Fedora 7 is known not to work, for example. @@ -9,7 +9,12 @@ Only the 'usb:' device is supported. If you're on Windows, do not attempt to run this through the serial driver. + + On Linux, a name of the form 'hid:path-to-hidraw,path-to-hiddev' is also supported. + You will need to use this only if the HID device nodes on your system are not named + /dev/hidrawN and /dev/hiddevN or /dev/usb/hiddevN. + This module implements the (undocumented) waypoint extensions introduced @@ -26,43 +31,3 @@ - - -GPSBabel supports the following Magellan receivers: - - 310 - 315 - Map330 - SporTrak Map Color - SporTrak Map - SporTrak Map Pro - SporTrak Map Topo - Meridian (green or yellow) - Meridian Gold - Meridian Platinum - Meridian Color - Explorist 100 (with aftermarket cable) - Explorist 200 (with aftermarket cable) - Explorist 300 (with aftermarket cable) - Explorist 210 - Explorist 300 - Explorist 400 - Explorist 500 - Explorist 600 - Explorist XL - - - - - This format is used for both the serial protocol used on the - devices with serial ports such as Map330 and Meridian and for - the files stored either in either the unit's internal memory - (Explorist 210, Explorist 400, Explorist 500, Explorist 600, - Explorist XL) or on removable memory. - - - If you specify a serial port for the file (.e.g. "COM1", "/dev/ttyS0") - to be read or written, GPSBabel will use serial protocol. Specifying - a file, either on local filesystem or on a mounted flash card reader, - will results in the file-based format being used. - -- 2.30.2